

//mapData数据结构
export interface MapdataType {
    name: string;
    value: [number, number, number]; //x,y,value  第一个x 第二个y  第三个value
    flyingCount:number;
    airportCount:number;
}
export const optionHandle = (regionCode, list, mapData) => {  
  let top = 45;  
  let zoom = ["china"].includes(regionCode) ? 1.05 : 1;  
  return {  
    tooltip: {  
      show: false,  
    },  
    legend: {  
      show: false,  
    },  
    // visualMap: {  
    //   seriesIndex: 0,  
    //   left: 20,  
    //   bottom: 20,  
    //   pieces: [  
    //     { gte: 1000, label: "1000个以上" },  
    //     { gte: 600, lte: 999, label: "600-999个" },  
    //     { gte: 200, lte: 599, label: "200-599个" },  
    //     { gte: 50, lte: 199, label: "49-199个" },  
    //     { gte: 10, lte: 49, label: "10-49个" },  
    //     { lte: 9, label: "1-9个" },  
    //   ],  
    //   inRange: {  
    //     color: [  
    //       "rgba(237,247,253,.8)",  
    //       "rgba(183,225,246,.9)",  
    //       "rgba(129,202,239,.9)",  
    //       "rgba(56,172,229,.9)",  
    //       "rgba(23,129,181,.9)",  
    //       "rgba(16,90,126,0.9)",  
    //       "rgba(87, 149, 214, 0.8)"  
    //     ],  
    //   },  
    //   textStyle: {  
    //     color: "#fff",  
    //   },  
    // },  
    geo: {  
      map: regionCode,  
      roam: false,  
      selectedMode: false,  
      zoom: zoom,  
      top: top,  
      show: false, // 不显示地理位置  
    },  
    series: [  
      {  
        name: "MAP",  
        type: "map",  
        map: regionCode,  
        data: list,  
        selectedMode: false,  
        zoom: zoom,  
        geoIndex: 1,  
        top: top,  
        tooltip: {  
          show: true,  
          formatter: function (params) {  
            if (params.data) {  
              return  "机场总数：" + params.data["airportCount"]+"<br/>" +'飞行中：'+params.data["flyingCount"];  
              
            } else {  
              return params.name;  
            }  
          },  
     
          backgroundColor: "rgba(0,0,0,.6)",  
          borderColor: "rgba(147, 235, 248, .8)",  
          textStyle: {  
            color: "#FFF",  
          },  
        },  
        label: {  
          show: false,  
          color: "#000",  
          formatter: function (val) {  
            if (val.data !== undefined) {  
              return val.name.slice(0, 2);  
            } else {  
              return "";  
            }  
          },  
          rich: {},  
        },  
        emphasis: {  
          label: {  
            show: false,  
          },  
          itemStyle: {  
            areaColor: {  
              type: "radial",  
              x: 0.5,  
              y: 0.5,  
              r: 0.8, 
              // 悬浮颜色 
              colorStops: [  
                // { offset: 0, color: "rgba(147, 235, 248, 0)" },  
                // { offset: 1, color: "rgba(56,172,229,.9)" }, // 保持与原始颜色一致  
                { offset: 0, color: "rgba(147, 235, 248, 0.6)" },  
                { offset: 1, color: "rgba(56,172,229,.9)" },
              ],  
              globalCoord: false,  
            },  
            borderWidth: 1, 
          // areaColor:  '#16336e',

          },  
        },  
        itemStyle: {  
          borderColor: "rgba(147, 235, 248, .8)",  
          borderWidth: 1,  
          // 设置渐变色
          areaColor: {  
            type: "radial",  
            x: 0.5,  
            y: 0.5,  
            r: 0.8, 
            // 默认颜色 
            colorStops: [  
              // 原项目色
              // { offset: 0, color: "rgba(147, 235, 248, 0)" },  
              // { offset: 1, color: "rgba(147, 235, 248, .2)" },  
              // { offset: 1, color: "rgba(147, 235, 248, .8)" },  
                { offset: 0, color: "rgba(147, 235, 248, 0)" },  
                { offset: 1, color: "rgba(56,172,229,.7)" }, // 保持与原始颜色一致  
              // gpt识别色
              // { offset: 0, color: "rgba(0, 136, 255, 0)" },  
              // { offset: 0, color: "rgba(0, 136, 255, 0.2)" },  
              // { offset: 1, color: "rgba(0, 136, 255, 0.7)" },  
              // ui图copy色
                // { offset: 0, color: "rgba(0, 136, 255, 1)" },  
            ],  
            globalCoord: false,  
          },  
        //  设置单色
          // areaColor:  '#1a3c81',

          // shadowColor: "rgba(0, 0, 0, 0.5)", // 更明显的阴影  
          // shadowOffsetX: -10, // 增大阴影偏移  
          // shadowOffsetY: 20, // 增大阴影偏移  
          // shadowBlur: 30, // 增大阴影模糊  
        },  
      },  
      {  
        type: "effectScatter",  
        coordinateSystem: "geo",  
        data: mapData,  
        symbolSize: function (val) {  
          return 4;  
        },  
        rippleEffect: {  
          brushType: "fill",  
          scale: 6,  
          period: 4,  
          color: "rgba(255,255,255, 1)",  
        },  
        tooltip: {  
          show: true,  
          formatter: function (params) {  
            if (params.data) {  
             if( params.data["airportCount"].length>1)
              return  "机场总数：" + params.data["airportCount"][2]+"<br/>" +'飞行中：'+params.data["flyingCount"][2];  

            } else {  
              return params.name;  
            }  
          },  
          // formatter: function (params) {  
          //   if (params.data) {  
          //     return params.name + "：" + params.data["value"][2];  
          //   } else {  
          //     return params.name;  
          //   }  
          // },  
          backgroundColor: "rgba(0,0,0,.6)",  
          borderColor: "rgba(147, 235, 248, .8)",  
          textStyle: {  
            color: "#FFF",  
          },  
        },  
        label: {  
          show: true,  
          formatter: (param) => param.name.slice(0, 2),  
          fontSize: 11,  
          offset: [0, 2],  
          position: "bottom",  
          textBorderColor: "#fff",  
          textShadowColor: "#000",  
          textShadowBlur: 10,  
          color: "#FFF",  
        },  
        itemStyle: {  
          color: "rgba(255,255,255,1)",  
          borderColor: "rgba(255,255,255,1)",  
          borderWidth: 4,  
          shadowColor: "#000",  
          shadowBlur: 10,  
        },  
      },  
    ],  
  };  
};
export const regionCodes: any = {
    "中国": {
        "adcode": "100000",
        "level": "country",
        "name": "中华人民共和国"
    },
    "新疆维吾尔自治区": {
        "adcode": "650000",
        "level": "province",
        "name": "新疆维吾尔自治区"
    },
    "湖北省": {
        "adcode": "420000",
        "level": "province",
        "name": "湖北省"
    },
    "辽宁省": {
        "adcode": "210000",
        "level": "province",
        "name": "辽宁省"
    },
    "广东省": {
        "adcode": "440000",
        "level": "province",
        "name": "广东省"
    },
    "内蒙古自治区": {
        "adcode": "150000",
        "level": "province",
        "name": "内蒙古自治区"
    },
    "黑龙江省": {
        "adcode": "230000",
        "level": "province",
        "name": "黑龙江省"
    },
    "河南省": {
        "adcode": "410000",
        "level": "province",
        "name": "河南省"
    },
    "山东省": {
        "adcode": "370000",
        "level": "province",
        "name": "山东省"
    },
    "陕西省": {
        "adcode": "610000",
        "level": "province",
        "name": "陕西省"
    },
    "贵州省": {
        "adcode": "520000",
        "level": "province",
        "name": "贵州省"
    },
    "上海市": {
        "adcode": "310000",
        "level": "province",
        "name": "上海市"
    },
    "重庆市": {
        "adcode": "500000",
        "level": "province",
        "name": "重庆市"
    },
    "西藏自治区": {
        "adcode": "540000",
        "level": "province",
        "name": "西藏自治区"
    },
    "安徽省": {
        "adcode": "340000",
        "level": "province",
        "name": "安徽省"
    },
    "福建省": {
        "adcode": "350000",
        "level": "province",
        "name": "福建省"
    },
    "湖南省": {
        "adcode": "430000",
        "level": "province",
        "name": "湖南省"
    },
    "海南省": {
        "adcode": "460000",
        "level": "province",
        "name": "海南省"
    },
    "江苏省": {
        "adcode": "320000",
        "level": "province",
        "name": "江苏省"
    },
    "青海省": {
        "adcode": "630000",
        "level": "province",
        "name": "青海省"
    },
    "广西壮族自治区": {
        "adcode": "450000",
        "level": "province",
        "name": "广西壮族自治区"
    },
    "宁夏回族自治区": {
        "adcode": "640000",
        "level": "province",
        "name": "宁夏回族自治区"
    },
    "浙江省": {
        "adcode": "330000",
        "level": "province",
        "name": "浙江省"
    },
    "河北省": {
        "adcode": "130000",
        "level": "province",
        "name": "河北省"
    },
    "香港特别行政区": {
        "adcode": "810000",
        "level": "province",
        "name": "香港特别行政区"
    },
    "台湾省": {
        "adcode": "710000",
        "level": "province",
        "name": "台湾省"
    },
    "澳门特别行政区": {
        "adcode": "820000",
        "level": "province",
        "name": "澳门特别行政区"
    },
    "甘肃省": {
        "adcode": "620000",
        "level": "province",
        "name": "甘肃省"
    },
    "四川省": {
        "adcode": "510000",
        "level": "province",
        "name": "四川省"
    },
    "天津市": {
        "adcode": "120000",
        "level": "province",
        "name": "天津市"
    },
    "江西省": {
        "adcode": "360000",
        "level": "province",
        "name": "江西省"
    },
    "云南省": {
        "adcode": "530000",
        "level": "province",
        "name": "云南省"
    },
    "山西省": {
        "adcode": "140000",
        "level": "province",
        "name": "山西省"
    },
    "北京市": {
        "adcode": "110000",
        "level": "province",
        "name": "北京市"
    },
    "吉林省": {
        "adcode": "220000",
        "level": "province",
        "name": "吉林省"
    }
}